#include <cstdio>
#include <cstring>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
stack<char>stk;
int main()
{
	char s[2020];
	int cnt = 0;
	while(scanf(" %s",s)!=EOF)
	{
		if(s[0]=='-') return 0;
		while(!stk.empty()) stk.pop();
		int ans = 0;
		int len = strlen(s);
		//printf("%d\n",len);
		for(int i = 0;i<len;i++)
		{
			if(s[i]=='{')
			{
				stk.push(s[i]);
			}
			else
			{
				if(stk.empty())
				{
					stk.push('{');
					ans++;
				}
				else
				{
					stk.pop();
				}
			}
		}
		int ans1 = stk.size();
		if(ans1%2) ans1 = (ans1-1)/2+1;
		else ans1 = ans1/2;
		ans = ans+ans1;
		printf("%d. %d\n",++cnt,ans);
	}
}
